package com.ruoyi.dispatch.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dispatch.domain.CoalWashType;
import com.ruoyi.dispatch.service.ICoalWashTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 洗煤煤种配置Controller
 * 
 * @author wuxiaofang
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/dispatch/coalWashType")
@Anonymous
public class CoalWashTypeController extends BaseController
{
    @Autowired
    private ICoalWashTypeService coalWashTypeService;

    /**
     * 查询洗煤煤种配置列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:coalWashType:list')")
    @GetMapping("/list")
    public TableDataInfo list(CoalWashType coalWashType)
    {
        startPage();
        List<CoalWashType> list = coalWashTypeService.selectCoalWashTypeList(coalWashType);
        return getDataTable(list);
    }

    /**
     * 导出洗煤煤种配置列表
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:coalWashType:export')")
    @Log(title = "洗煤煤种配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CoalWashType coalWashType)
    {
        List<CoalWashType> list = coalWashTypeService.selectCoalWashTypeList(coalWashType);
        ExcelUtil<CoalWashType> util = new ExcelUtil<CoalWashType>(CoalWashType.class);
        util.exportExcel(response, list, "洗煤煤种配置数据");
    }

    /**
     * 获取洗煤煤种配置详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:coalWashType:query')")
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return success(coalWashTypeService.selectCoalWashTypeByTypeId(typeId));
    }

    /**
     * 新增洗煤煤种配置
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:coalWashType:add')")
    @Log(title = "洗煤煤种配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CoalWashType coalWashType)
    {
        return toAjax(coalWashTypeService.insertCoalWashType(coalWashType));
    }

    /**
     * 修改洗煤煤种配置
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:coalWashType:edit')")
    @Log(title = "洗煤煤种配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CoalWashType coalWashType)
    {
        return toAjax(coalWashTypeService.updateCoalWashType(coalWashType));
    }

    /**
     * 删除洗煤煤种配置
     */
    //@PreAuthorize("@ss.hasPermi('dispatch:coalWashType:remove')")
    @Log(title = "洗煤煤种配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(coalWashTypeService.deleteCoalWashTypeByTypeIds(typeIds));
    }
}
